<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/24
 * Time: 10:24
 */
namespace App\Http\Controllers;

use Gregwar\Captcha\CaptchaBuilder;
use Session;
class CodeController extends Controller
{
    public function captcha()
    {
        $builder = new CaptchaBuilder();
        $builder->build(150,32);//获取验证码内容
        $phrase = $builder->getPhrase();
        //把内容存入session
        Session::flash('milkcaptcha',$phrase);//存储验证码
        ob_clean(); //清除缓存
        return response($builder->output())->header('Content-type','image/jpeg'); //把验证码数据以jpeg图片的格式输出
    }
}